<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script>
        else if (obj.event==='edit'){
//实现编辑功能
            layer.open({
                type:1,
                title:'编辑商品信息',
                context:'updateProduct.html',
                maxmin:true,
                area:['500px','450px'],
                btn:['确认','取消'],
                yes:function (index, layero) {
//回调的数值
                    var id= $(layero).find('iframe')[0].contentWindow.id.value;
                    var name= $(layero).find('iframe')[0].contentWindow.document.getElementById('name').value;
                    var price= $(layero).find('iframe')[0].contentWindow.document.getElementById('price').value;
//同步数据表格中的数据
                    obj.update({
                        'id':id,
                        'name':name,
                        'price':price
                    })

                    $.ajax({
                        url:'/taobei_web/pro/updateProductById',
                        type:'post',
                        data:{
                            'id':id,
                            'name':name,
                            'price':price
                        },
                        dataType:'json',
                        success:function (respBean) {
                            layer.msg(respBean.msg)
                        },
                        error:function (respBean) {
                            layero.msg("修改失败")
                        }
                    })
                    layer.close(index);
                },
                success:function (layero, index) {
                    var div = layero.find('iframe').contents().find('#useradmin');
                    var body = layer.getChildFrame('body',index);
                    var iframeWindow = window['layui-layer-iframe'+index]
                    body.find('#id').val(data.id);
                    body.find('#name').val(data.name);
                    body.find('#price').val(data.price);
                }
            });
        }
    </script>
</body>
</html>